import {formatDate, ossPut, isBlank, isFlag} from '@/utils/util'
import appUtils from '@/utils/util'

export default {}
export const imageUtils = (src, image) => {
  let imageSrc
  let headImg = appUtils.myImage
  if (!isFlag(src.indexOf('http://'), -1) || !isFlag(src.indexOf('https://'), -1)) {
    headImg = ''
  }
  if (!isBlank(image)) {
    if (isFlag(image.indexOf('http://'), -1) && isFlag(image.indexOf('https://'), -1)) {
      if (!isFlag(image.indexOf('data:image/'), -1)) {
        imageSrc = image
      } else {
        imageSrc = headImg + src + image
      }
    } else {
      imageSrc = image
    }
  }
  return imageSrc
}

export const orangeImageUtils = (src, image) => {
  let imageSrc
  if (!isBlank(image)) {
    if (image.indexOf('http://') < 0 && image.indexOf('https://') < 0) {
      if (image.indexOf('data:image/') > -1) {
        imageSrc = image
      } else {
        if (image.indexOf('/compress') < 0) {
          imageSrc = appUtils.myImage + src + image
        } else {
          imageSrc = appUtils.myImage + src + image
        }
      }
    } else {
      imageSrc = image
    }
  }
  return imageSrc
}


export const blhcVideoImage = (src, image, s) => {
  let videoUrl
  if (!isBlank(image)) {
    videoUrl = 'https://www.lianlaoban.cn/myImage/' + src + image + '?x-oss-process=video/snapshot,t_' + s * 1000 + ',f_jpg,w_800,h_600'
  }
  return videoUrl
}
export const videoPlay = (src, image) => {
  let videoUrl
  let headImg = appUtils.myImage
  if (!isFlag(src.indexOf('http://'), -1) || !isFlag(src.indexOf('https://'), -1)) {
    headImg = ''
  }
  if (!isBlank(image)) {
    if (isFlag(image.indexOf('http://'), -1) && isFlag(image.indexOf('https://'), -1)) {
      videoUrl = headImg + src + image
    } else {
      videoUrl = headImg + src + image
    }
  }
  return videoUrl
}
export const fileUrlUtils = (src, image) => {
  let imageSrc
  let headImg = appUtils.myImage
  if (!isFlag(src.indexOf('http://'), -1) || !isFlag(src.indexOf('https://'), -1)) {
    headImg = ''
  }
  imageSrc = headImg + src + image
  return imageSrc
}
